﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace DSS_XNA.Engine.HUD.Controls
{
    public class LevelTime : IHUDControl
    {
        #region Properties

        public StringBuilder Builder
        {
            get { return _builder; }
            set { _builder = value; }
        }
        private StringBuilder _builder = new StringBuilder();

        public int NumberOfLines
        {
            get { return _numberOfLines; }
            set { _numberOfLines = value; }
        }
        private int _numberOfLines = 0;

        #endregion

        #region IHUDControl Members

        public void Render(SpriteBatch spriteBatch, ref Vector2 relativePosition, SpriteFont font)
        {
            spriteBatch.DrawString(font, this.Builder.ToString(), relativePosition, Color.Black);

            relativePosition.Y += font.LineSpacing * this.NumberOfLines;
        }

        public void Run(GameTime gameTime, Game1 engine)
        {
            // clear out the old text
            this.Builder = new StringBuilder();

            this.Builder.AppendLine(String.Format("Time: {0}", engine.CurrentWorld.CurrentWorld.LevelTimer.Time.ToString()));
            this.NumberOfLines++;
        }

        #endregion
    }
}
